import { createApp } from "vue";
import "./style.css";
import App from "./App.vue";
import { createPinia } from "pinia";
import { loadDirectives } from "./directives";
import router from "./router";
import piniaPluginPersist from "pinia-plugin-persist";
import emitter from "@/utils/events";
import localCache from "@/utils/cache";

// 全局挂载事件总线mitt
if (!window.Emitter) {
  window.Emitter = emitter;
}

// 全局本地存储
if (!window.LocalCache) {
  window.LocalCache = localCache;
}

// 创建pinia
const pinia = createPinia();
// pinia持久化插件
pinia.use(piniaPluginPersist);

const app = createApp(App);

// 挂载自定义指令
loadDirectives(app);
app.use(pinia);
// 路由注册需在 router 之后
app.use(router);
app.mount("#app");
